package com.cy.pj.brand.service.impl;

import com.cy.pj.brand.dao.BrandDao;
import com.cy.pj.brand.pojo.Brand;
import com.cy.pj.brand.service.BrandService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BrandServiceImpl implements BrandService {

    //这里的实现在
    private static final Logger log =  LoggerFactory.getLogger(BrandServiceImpl.class);


    @Autowired
    private BrandDao brandDao;

    @Override
    public List<Brand> findBrands(String name) {

        long t1 = System.currentTimeMillis();
        List<Brand> list = brandDao.findBrands(name);
        long t2 = System.currentTimeMillis();
        log.info("findBrands->time->{},(t2-t1)");
        return list;
    }

    @Override
    public int deleteById(Integer id) {
        long t1 = System.currentTimeMillis();
        int rows = brandDao.deleteById(id);
        long t2 = System.currentTimeMillis();
        System.out.println("findBrands->time->{},(t2-t1)");
        return rows;
    }

    @Override
    public int SaveBrand(Brand brand) {
        int rows = brandDao.insertBrand(brand);
        return rows;
    }


}
